// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import axios from "axios"
import VueRouter from 'vue-router'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

// 3设置基础路径
axios.defaults.baseURL = 'http://127.0.0.1:8669/'
// 4axios方法添加到Vue的原型上
Vue.prototype.$axios = axios
Vue.use(VueRouter)

Vue.config.productionTip = false

import 'babel-polyfill'
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
axios.interceptors.request.use(

  config => {
    config.headers = {
      'Content-Type': 'application/json' //  注意：设置很关键
    }

    if (localStorage.getItem('adtoken')) {

      config.headers.token = localStorage.getItem('adtoken');
      console.log('请求头中携带token')
    }

    return config;

  },

  error => {

    return Promise.reject(error);
  });
